#!/usr/bin/perl


# This file is part of qorg11 blog

# qorg11 blog is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# qorg11 blog is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with qorg11 blog.  If not, see <https://www.gnu.org/licenses/>.


use CGI;
use DateTime;
use SQLite::DB;
use POSIX;
my $db = SQLite::DB->new("articles.sqlite");
$db->connect;
my $Time = time();
my $date = strftime('%Y-%m-%dT%H:%M:%SZ', localtime($Time)), "\n";
my $q = CGI->new;
print $q->header;
my $title =  $q->param("title");
my $content = $q->param("content");
my $passwd = "..pIzZ9BCBKWY";
if (crypt($q->param("passwd"),"$1......") ne $passwd) {
    print "Nope";
    die;
}
else {
    $db->exec("INSERT INTO blog (TITLE, CONTENT, DATE) VALUES (?, ?, ?)",$title, $content, $date) || print $db->get_error;
}
